GtkWidgetPath: Add methods to check topmost widget type.
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 18 Jun 2010 14:59:14 +0000 (16:59 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:37:12 +0000 (15:37 +0100)
gtk/gtkwidgetpath.c
gtk/gtkwidgetpath.h

index 257327361632fab91b02e7d7b1573633edcb4245..c39b4c75d1883654911d94afaa5c32d5d7687ce8 100644 (file)
@@ -305,6 +305,35 @@ gtk_widget_path_iter_has_region (GtkWidgetPath      *path,
   return TRUE;
 }
 
+GType
+gtk_widget_path_get_widget_type (const GtkWidgetPath *path)
+{
+  GtkPathElement *elem;
+
+  g_return_val_if_fail (path != NULL, G_TYPE_INVALID);
+
+  elem = &g_array_index (path->elems, GtkPathElement, 0);
+  return elem->type;
+}
+
+gboolean
+gtk_widget_path_is_type (const GtkWidgetPath *path,
+                         GType                type)
+{
+  GtkPathElement *elem;
+
+  g_return_val_if_fail (path != NULL, FALSE);
+  g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE);
+
+  elem = &g_array_index (path->elems, GtkPathElement, 0);
+
+  if (elem->type == type ||
+      g_type_is_a (elem->type, type))
+    return TRUE;
+
+  return FALSE;
+}
+
 gboolean
 gtk_widget_path_has_parent (const GtkWidgetPath *path,
                             GType                type)
index 7020c826a3baf6f9bd633a148240fb6af11ffc31..9e2d0edf1e018193d1dbe192aec0b859669f39a0 100644 (file)
@@ -68,8 +68,12 @@ gboolean gtk_widget_path_iter_has_region    (GtkWidgetPath      *path,
                                              const gchar        *name,
                                              GtkChildClassFlags *flags);
 
-gboolean        gtk_widget_path_has_parent          (const GtkWidgetPath *path,
-                                                     GType                type);
+GType           gtk_widget_path_get_widget_type (const GtkWidgetPath *path);
+
+gboolean        gtk_widget_path_is_type    (const GtkWidgetPath *path,
+                                            GType                type);
+gboolean        gtk_widget_path_has_parent (const GtkWidgetPath *path,
+                                            GType                type);
 
 G_END_DECLS